package com.wellgoon.test.exam;

import java.util.Scanner;

/**
 * 单词倒排
 */
public class HJ31 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入小于5000个字符的字符串");
        try {
            while (sc.hasNext()) {
                String str = sc.nextLine();
                String[] strArray = str.trim().split("[^a-zA-Z']+");
                StringBuilder sb = new StringBuilder();
                for (int i = strArray.length - 1; i >= 0; i--) {
                    sb.append(strArray[i]).append(" ");
                }
                System.out.println("字符串[" + str + "]倒排后为：" + sb.toString());
                System.out.println("请输入小于5000个字符的字符串");
            }
        } catch (Exception e) {
            System.err.println("执行错误:" + e.getMessage());
        } finally {
            sc.close();
        }

    }
}
